package thread;

public class Demo12 {


    /**
     * wait \  notify                    synchronized,锁的同一个对象
     * @param args
     */
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Thread t1 = new Thread(()->{
            System.out.println("wait 开始");
            synchronized (locker){
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("wait 结束");
        });
        t1.start();

        Thread.sleep(1000);

        Thread t2 = new Thread(()->{
            System.out.println("notify 开始");
            synchronized (locker){
                locker.notify();
            }
            System.out.println("notify 结束");
        });
        t2.start();
    }

}
